<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
</html>
<script>
  var arr = [5, 3, 3, 8, 8, 6, 6, 1, 4];
  var result = [];
  arr.forEach(function (item) {
    if (!result.includes(item)) {
      result.push(item);
    }
  });

  console.log(result);
  // [1, 3, 4, 5, 6, 8]
  // 数组去重
  // 1.forEach循环遍历数组
  // 2.includes方法判断数组中是否有当前元素
  // 3.如果没有，则push进result数组queue
  // 4.返回result数组queue

  console.log('双中循环方法');
  var arr1 = [1, 2, 3, 3, 4, 5, 6, 8]
var result = []
for (var i = 0; i < arr1.length; i++) {
  let _hasItem = false
  for (var j = 0; j < result.length; j++) {
    if (arr1[i] === result[j]) {
      _hasItem = true
      break
    }
  }
  if (!_hasItem) {
    result.push(arr1[i])
  }
}
console.log(result)



 console.log('new Set方法');
var arr = [5,5, 3, 3, 8, 8, 6, 6];
var result = [...new Set(arr)]
 console.log(result); // [5, 3, 8, 6]
</script>
